home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / sun / lib2 / arg_vc.c next >
Encoding:
C/C++ Source or Header  |  1993-03-25  |  2.2 KB  |  81 lines

  1. /*    ARG_VC . C
  2. #
  3. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  4.  
  5. This software is copyright (C) by the Lawrence Berkeley Laboratory.
  6. Permission is granted to reproduce this software for non-commercial
  7. purposes provided that this notice is left intact.
  8.  
  9. It is acknowledged that the U.S. Government has rights to this software
  10. under Contract DE-AC03-765F00098 between the U.S.  Department of Energy
  11. and the University of California.
  12.  
  13. This software is provided as a professional and academic contribution
  14. for joint exchange. Thus, it is experimental, and is provided ``as is'',
  15. with no warranties of any kind whatsoever, no support, no promise of
  16. updates, or printed documentation. By using this software, you
  17. acknowledge that the Lawrence Berkeley Laboratory and Regents of the
  18. University of California shall have no liability with respect to the
  19. infringement of other copyrights by any part of this software.
  20.  
  21. For further information about this notice, contact William Johnston,
  22. Bld. 50B, Rm. 2239, Lawrence Berkeley Laboratory, Berkeley, CA, 94720.
  23. (wejohnston@lbl.gov)
  24.  
  25. For further information about this software, contact:
  26.     Jin Guojun
  27.     Bld. 50B, Rm. 2275, Lawrence Berkeley Laboratory, Berkeley, CA, 94720.
  28.     g_jin@lbl.gov
  29.  
  30. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  31. %
  32. %        arguments - argc & argv - handler
  33. %    return 0, to both routines, means failure.
  34. %
  35. %    must include <stdlib.h>
  36. %
  37. % AUTHOR:    Jin Guojun - LBL    04/01/91
  38. */
  39.  
  40. #include <math.h>
  41. #include <stdlib.h>
  42. #include "imagedef.h"
  43.  
  44. isdecimal(s, f)
  45. register    f;
  46. {
  47.     switch (s) {
  48.     case '+':
  49.     case '-':    f = isfloat(f);    break;
  50.     case '.':    f = isdigit(f);    break;
  51.     default:    f = isfloat(s);
  52.     }
  53. return    f;
  54. }
  55.  
  56. avset(ac, av, i, c, s)
  57. register char**    av;
  58. register int    *i, *c, s;
  59. {
  60. register int    cur=av[*i][*c], curnotnum= !s && !isdecimal(cur, av[*i][*c+1]),
  61.         nextisnum;
  62.     if (*i+1 < ac) {
  63.     nextisnum = isdecimal(*av[*i+1], av[*i+1][1]);
  64.     if (!cur && (nextisnum | s) || curnotnum && nextisnum)
  65.         ++*i,  *c ^= *c;
  66.     else
  67. s_only:        if (curnotnum)    return    0;
  68.     }
  69.     else    goto    s_only;
  70. return    av[*i][*c];
  71. }
  72.  
  73. double
  74. arget(ac, av, i, c)
  75. register int    ac, *i, *c;
  76. register char**    av;
  77. {
  78. if (avset(ac, av, i, c, 0))    return    atof(av[*i] + *c);
  79. return    0;
  80. }
  81.